<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net.cn/npm/bootstrap-icons@1.3.0/font/bootstrap-icons.css" />
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans",
                "Helvetica Neue", sans-serif;
            font-size: 1rem;
            line-height: 1.7;
            background-color: #f4f4f4;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
        }

        .container {
            background-color: #fff;
            border-radius: 5px;
            box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
            max-width: 300px;
            margin: 10px auto;
            padding: 1rem;
        }

        h1 {
            padding: 5px 0;
            font-size: 1.2rem;
            color: #111;
            text-align: center;

        }

        input {
            padding: 10px;
            font-size: 14px;
            border-radius: 5px;
            outline: none;
            width: 100%;
            border: solid 1px #ccc;
        }

        form i {
            margin-left: -30px;
            cursor: pointer;
        }

        button {
            box-sizing: border-box;
            width: 100%;
            padding: 3%;
            background: #007bff;
            border: none;
            color: #fff;
            font-size: 14px;
            border-radius: 5px;
        }

        button:hover {
            background: #0069d9;
            cursor: pointer;
        }

        .submit {
            margin-top: 10px;
        }
    </style>
</head>

<body>
    <div class="container">
        <h1>登 录</h1>
        <form action="" method="post" autocomplete="off">
            <p>
                <label for="username">用户名: </label>
                <input type="text" name="username" id="username" placeholder="请输入用户名" />
            </p>
            <p>
                <label for="password">密码: </label>
                <input type="password" name="password" id="password" placeholder="请输入密码" />
                <i class="bi bi-eye-slash" id="togglePassword"></i>
            </p>
            <button type="submit" id="submit" class="submit">登 录</button>
        </form>
    </div>

    <script>
        const togglePassword = document.querySelector("#togglePassword");
        const password = document.querySelector("#password");

        togglePassword.addEventListener("click", function () {
            // toggle the type attribute
            const type = password.getAttribute("type") === "password" ? "text" : "password";
            password.setAttribute("type", type);
            // toggle the icon
            this.classList.toggle("bi-eye");
        });

        // prevent form submit
        const form = document.querySelector("form");
        form.addEventListener('submit', function (e) {
            e.preventDefault();
        });

    </script>

</body>

</html>